package com.earthchen.hbase.phoenix;

import java.net.URI;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

/**
 * phoenix和jdbc流程完全一样
 *
 * @author: EarthChen
 * @date: 2018/07/29
 */
public class PhoenixTest {

    private static final String URL = "jdbc:phoenix:127.0.0.1:2181";

    public static void main(String[] args) throws Exception {
        Class.forName("org.apache.phoenix.jdbc.PhoenixDriver");

        Connection connection = DriverManager.getConnection(URL);

        PreparedStatement statement = connection.prepareStatement("select * from person");

        ResultSet resultSet = statement.executeQuery();

        while (resultSet.next()) {
            System.out.println(resultSet.getString("name"));
            System.out.println(resultSet.getString("age"));
            System.out.println(resultSet.getString("id"));
        }

        statement.close();
        connection.close();

    }
}
